<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/09/20 23:46:58 $)
// $RCSfile: staff_userlookup.php,v $ : $Revision: 1.5 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

require_once ("./includes/functions_html.php");
require_once ("./includes/functions_sqlsearch.php");
require_once ("./modules/core/functions_userlookup.php");
require_once ("./includes/TreeMenu/TreeMenu.php");
$template->loadLanguageSection("staff_userlookup");

$template->assign("treemenu", true);

if ($_GET["action"] == "search")
{
	echo searchUsers(str_replace("*", "%",str_replace("%","",$_GET["query"])));
	exit;
}

if (empty($_GET["action"]))
{
	$template->assign("documenttitle", $_SWIFT["language"]["viewparserlog"]);
	echo $template->displayTemplate("header.tpl");
	echo '<body onLoad="javascript:focusSearchField();">';

	?>
	<script language="Javascript">
	function focusSearchField()
	{
		document.userlookupform.searchquery.focus();
	}
	setTimeout("keywordCheck('<?=addslashes($_GET["formname"])?>', '<?=addslashes($_GET["formfield"])?>');", 1000);
	</script>
	<?

	echo '<table width="100%"  border="0" cellspacing="0" cellpadding="5"><tr><td>';
	printFormStart("userlookupform", "index.php", "POST", false, "", "javascript: return false;");
	printMainTableHeader($_SWIFT["language"]["lookuptitle"]);

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["searchquery"] .'</span></td>
	<td align="left"><input type="text" size="40" name="searchquery" value="" class="swifttext"></td></tr>';


	$menu = new HTML_TreeMenu();
	$usersnode = &$menu->addItem(new HTML_TreeNode(array('text' => "&nbsp;". $_SWIFT["language"]["users"], 'icon' => "icon_user.gif", 'expandedIcon' => "icon_user.gif")));
	$contactsnode = &$menu->addItem(new HTML_TreeNode(array('text' => "&nbsp;". $_SWIFT["language"]["contacts"], 'icon' => "icon_contacts.gif", 'expandedIcon' => "icon_contacts.gif", 'expanded' => true)));

	$treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => stripTrailingSlash($_SWIFT["themepath"]), 'defaultClass' => 'treeMenuDefault'));


	ob_start();
	?><div id="searchdiv" style="position:relative; width:100%; height:300px; background-color:#ffffff; overflow:auto;"><?
	$treeMenu->printMenu();
	?></div><?
	$contents = ob_get_contents();
	ob_end_clean();

	printDescRow($contents, "2", "defaultrow");
	printMainTableFooter();
	printFormEnd();
	echo '</td></tr></table></body>';

	echo $template->displayTemplate("footer.tpl");

}
?>